#pragma once

#include "messages.hpp"
#include "util/RingBuffer.hpp"

namespace actor {

namespace details {

struct FixedString {
  static constexpr size_t SZ = 50;
  FixedString() = default;
  FixedString(const char* ptr, size_t sz);
  char data[SZ];
  size_t size;
};

} // namespace details

struct UARTActor : rl::Actor<3> {
  static constexpr size_t BUFF_SZ = 5;

  using Parent = Actor<3>;
  using Buffer = util::RingBuffer<details::FixedString, BUFF_SZ>;

  void initialize() override;
  void on_log(message::LogStatic &message);
  void on_ready(message::UARTReady &message);
  void send_next(bool from_interrupt = false);
  void send_start();

  Buffer buff;
  bool ready;
  const char *ptr;
  const char *end;
};

} // namespace actor
